<?

//Initiate Authenticate
SecurityRedirect ();

//initiate Vars 
define("PRIMARY_KEY","kdcust");
$KEY[]         = array("PRIMARY_KEY"=>PRIMARY_KEY);
$FileName      = "ais_transaction_receipt_principal.php";
$FileTemplate = "ais_transaction_receipt_principal_container.html";

$PageSize      = 10 ;
$TableName     = "$DBCoins.coins_container_process";
$HTMLGridList  = "ContainerGrid";

//************ FORM ACTION **************
	if (GetParam("Action","")=="Delete") {
		DeleteRecord ("txtCheck",$PageSize);
	}
	
	if (GetParam("PRCODE","")) {
//		$SQL = "SELECT concat(PRNAME,' - (',PRCODE,')') FROM $DBCoins.tblprincipal WHERE PRCODE='".GetParam("PRCODE","")."'";
		$SQL = "SELECT PRNAME FROM $DBCoins.tblprincipal WHERE PRCODE='".GetParam("PRCODE","")."'";
		$PrincipalName = $DBConnection->dbc->get_var($SQL);
	}


//Initiate Database Table For Search;

$FCode = GetParam("crnoSearch","");
$transDate = GetParam("transDate","");

$FormName = GetParam("FormName","");
//******* DATABASE FORM QUERY ***********
$SQL = "SELECT * FROM $TableName ";
$SQLCount = "SELECT count(*) FROM $TableName ";
$WHERE = "CPOPR='".GetParam("PRCODE","")."'";
if ($FNama) 
	if (strlen($WHERE)) $WHERE .= " AND "." nama like '".$FNama."%'";
	else $WHERE .= " nama like '".$FNama."%'";	
if ($FCode) 
	if (strlen($WHERE)) $WHERE .= " AND "." kodecustomer like '".$FCode."%'";
	else $WHERE .= " kodecustomer like '".$FCode."%'";

	if (strlen($WHERE))	$WHERE = " WHERE ".$WHERE;
	else $WHERE = " WHERE 1";

$SQL = $SQL.$WHERE;
$SQLCount = $SQLCount.$WHERE;

//******* SHOW FORM CONTENT *********
$PageNum = 1;
$RecCnt = $DBConnection->dbc->get_var($SQLCount) ; 

if (GetParam("PageNum","")) $PageNum  = GetParam("PageNum","");

$TBS = new clsTinyButStrong ;
$TBS->LoadTemplate($MOD_TEMPLATE_DIR."/".$FileTemplate);
$TBS->MergeBlock("bln",$KEY);
$TBS->MergeBlock("blg",$DBMysql,$SQL,$PageSize,$PageNum,$RecCnt);
$TBS->MergeNavigationBar('nv',array('size'=>10,'pos'=>'centred'),$PageNum,$RecCnt,$PageSize) ; 
$TBS->Show();


function DeleteRecord ($sequence_name,$PageSize) {
	global $DBConnection,$FileName;	
	for ($x=1;$x<=$PageSize;$x++) {		
		if (GetParam($sequence_name.$x,""))	{
			$DBConnection->Delete("tblcustomer",$sequence_name.$x);
	    }
	}
	header("Location: $FileName");
	exit;	
	
}

?>